import Vue from 'vue'
import Vuex from 'vuex'
import api from '@/api/index.js'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		code: "",
		access_token: "",
		openid: "obD_t1CJQMV3LhLx0psum-iUdudI", // obD_t1DQGbgVrCFnluGvhS12uhR8
		appid: "",
		secret: "",
		masterColor: "#335FFC",
		isLogin: false,
		tabbar: [],
		userInfo: '',
		myInfo: '',
		campusList: [],
		// ddjy
		courseData: {},
		messageList: [],
		taskItem:''
	},
	mutations: {
		setTaskItem(state, rawData) {
			state.taskItem = rawData;
		},
		setMyInfo(state, rawData) {
			state.myInfo = rawData;
		},
		setActivityStatus1(state, rawData) {
			state.activityStatus1 = rawData;
		},
		setActivityData(state, rawData) {
			state.activityData = rawData;
		},
		setUserInfo(state, rawData) {
			state.userInfo = rawData;
		},
		setAccessToken(state, rawData) {
			state.access_token = rawData;
		},
		setOpenid(state, rawData) {
			state.openid = rawData;
		},
		setCode(state, rawData) {
			state.code = rawData;
		},
		setActivityItem(state, rawData) {
			state.activityItem = rawData;
		},
		setCaseTabsList(state, rawData) {
			state.caseTabsList = rawData;
		},
		setCaseList(state, rawData) {
			state.caseList = rawData;
		},
		setCaseListFinished(state, b) {
			state.caseListFinished = b;
		},
		setCaseItem(state, rawData) {
			state.caseItem = rawData;
		},
		setSwipeList(state, rawData) {
			state.swipeList = rawData;
		},
		setAppid(state, rawData) {
			state.appid = rawData;
		},
		setSecret(state, rawData) {
			state.secret = rawData;
		},
		setTabbar(state, rawData) {
			state.tabbar = rawData;
		},
		setColor(state, rawData) {
			state.mainColor = rawData;
			console.log(state.mainColor)
		},
		setMasterColor(state, rawData) {
			state.masterColor = rawData;
			console.log(state.masterColor)
		},
	},
	actions: {
		async getCaseList(context, params = {
			type_id: 0,
			pageNo: 1,
			pageSize: 10
		}) {
			await api.getCaseList(params).then(res => {
				context.commit('setCaseList', res.data);
				return res.data;
			})
		},
	},
	getters: {
		getOpenid(state) {
			return state.openid;
		},
		getAppid(state) {
			return state.appid;
		},
		getSecret(state) {
			return state.secret;
		},
		getMasterColor(state) {
			return state.masterColor;
		},
		getMainColor(state) {
			return state.masterColor;
		},
		getTabbar(state) {
			return state.tabbar;
		},
		getSwipeList(state) {
			return state.swipeList;
		},
		getCaseTabsList(state) {
			return state.caseTabsList;
		},
		getCaseList(state) {
			return state.caseList;
		},
		getCaseListFinished(state) {
			return state.caseListFinished;
		},
		getCaseItem(state) {
			return state.caseItem;
		}
	},
	modules: {}
})
